package com.welsy.util
{
	import flash.utils.ByteArray;
	import mx.collections.ArrayCollection;
	
	public class ObjectClonator
	{
		
		/**
		 * Create a clone copy of the original object
		 * (in order to avoid reference passing)
		 **/
		public static function clone(source:Object):*{
   			var myBA:ByteArray = new ByteArray();
    		myBA.writeObject(source);
    		myBA.position = 0;
    		return(myBA.readObject());
 		 }
		
		
		public static function cloneArrayCollection(coll : ArrayCollection) : ArrayCollection {
			var ret : ArrayCollection = new ArrayCollection;
			for each(var it : Object in coll) {
				ret.addItem(it);
			}
			return ret;
		}
	}
}